#include <unittest/unittest.h>

#include <cusp/array2d.h>
#include <cusp/coo_matrix.h>
#include <cusp/csr_matrix.h>
#include <cusp/dia_matrix.h>
#include <cusp/ell_matrix.h>
#include <cusp/hyb_matrix.h>

#include <cusp/frobenius_norm.h>

template<typename MatrixType>
void TestFrobenius(void)
{
	typedef typename MatrixType::value_type ValueType;

	cusp::array2d<ValueType, cusp::host_memory> A(3,3);
	A(0,0) = 12.0; A(0,1) = -51.0;  A(0,2) = 4.0;
	A(1,0) =  6.0; A(1,1) = 167.0;  A(1,2) = -68.0;
	A(2,0) = -4.0; A(2,1) =  24.0;  A(2,2) = -41.0;

	// TODO: need a better test for hyb matrix format

	MatrixType B(A);
	ASSERT_ALMOST_EQUAL(ValueType(193.8634),
		cusp::frobenius_norm(B));
}
DECLARE_MATRIX_UNITTEST(TestFrobenius);

